home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / Menu Controls / ShapeCommands.h < prev    next >
Encoding:
Text File  |  1995-06-24  |  10.0 KB  |  332 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
  2. // ShapeCommands.h
  3.  
  4. #ifndef __SHAPECOMMANDS__
  5. #define __SHAPECOMMANDS__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __UCOMMAND__
  10. #include <UCommand.h>
  11. #endif
  12.  
  13. #ifndef __UTEAROFFMENUVIEW__
  14. #include <UTearOffMenuView.h>
  15. #endif
  16.  
  17. // DrawShapes
  18.  
  19. #ifndef __BETTERFEEDBACK__
  20. #include "BetterFeedback.h"
  21. #endif
  22.  
  23. #ifndef __USHAPELIST__
  24. #include "UShapeList.h"
  25. #endif
  26.  
  27. //--------------------------------------------------------------------------------------------------
  28.  
  29. class TPatternsPalette;
  30. class TShapeView;
  31. class TShapeDocument;
  32.  
  33. //--------------------------------------------------------------------------------------------------
  34. // CLASS TShapeCommand - common ancestor for all commands operating on one or more shapes
  35. //--------------------------------------------------------------------------------------------------
  36. class TShapeCommand : public TBetterFeedbackCmd
  37. {
  38.     MA_DECLARE_CLASS;
  39.  
  40.   public:
  41.     TShapeCommand();        // Constructor
  42.     void IShapeCommand(CommandNumber itsCommandNumber,
  43.                        TShapeView* itsShapeView,
  44.                        Boolean canUndo,
  45.                        Boolean causesChange,
  46.                        const VPoint& theMouse,
  47.                        Boolean betterFeedbackDesired);
  48.  
  49.   protected:
  50.     TShapeView*        fShapeView;
  51.     TShapeDocument*    fShapeDocument;
  52. };
  53.  
  54. //--------------------------------------------------------------------------------------------------
  55. // CLASS TShapeSelector - this command demonstrates the use of a command object that is not saved
  56. //                          and that does not commit the last command. The same effect could have
  57. //                          been achieved by selecting the shapes in the TrackMouse method.
  58. //--------------------------------------------------------------------------------------------------
  59. class TShapeSelector : public TShapeCommand
  60. {
  61.     MA_DECLARE_CLASS;
  62.  
  63.   public:
  64.     TShapeSelector();        // Constructor
  65.     void IShapeSelector(CommandNumber itsCommandNumber,
  66.                         TShapeView* itsShapeView,
  67.                         const VPoint& theMouse);
  68.  
  69.     virtual void DoIt();    // Override
  70.  
  71.     virtual void TrackFeedback(TrackPhase aTrackPhase,
  72.                                 const VPoint& anchorPoint,
  73.                                 const VPoint& previousPoint,
  74.                                 const VPoint& nextPoint,
  75.                                 Boolean mouseDidMove,
  76.                                 Boolean turnItOn);    // Override
  77.  
  78.     virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
  79.                                  VPoint& anchorPoint,
  80.                                  VPoint& previousPoint,
  81.                                  VPoint& nextPoint,
  82.                                  Boolean mouseDidMove);    // Override
  83.  
  84.   private:
  85.     long        fLastMarch;
  86.     Pattern        fAnts;
  87.     CRect        fBounds;
  88.     Boolean        fShiftKey;
  89. };
  90.  
  91. //--------------------------------------------------------------------------------------------------
  92. // CLASS TShapeDragger - 
  93. //--------------------------------------------------------------------------------------------------
  94. class TShapeDragger : public TShapeCommand
  95. {
  96.     MA_DECLARE_CLASS;
  97.  
  98.   public:
  99.     TShapeDragger();        // Constructor
  100.     void IShapeDragger(TShapeView* itsShapeView,
  101.                        const VPoint& theMouse);
  102.  
  103.     virtual void DoIt();    // Override
  104.     virtual void UndoIt();    // Override
  105.     virtual void RedoIt();    // Override
  106.  
  107.     void MoveBy(long deltaH, long deltaV);
  108.  
  109.     virtual void TrackConstrain(TrackPhase aTrackPhase,
  110.                                 const VPoint& anchorPoint,
  111.                                 const VPoint& previousPoint,
  112.                                 VPoint& nextPoint,
  113.                                 Boolean mouseDidMove);    // Override
  114.     // Only if gConstrainDrags is true is a shapeDragger marked as constraining the mouse,
  115.     // so be sure to make gConstrainDrags TRUE before mousing down on something you want to
  116.     // drag under constraint.
  117.     // You manipulate the gConstrainDrags flag through a toggle in the 'More Debug' menu,
  118.     // which you get displayed by hitting Command-D.
  119.  
  120.     virtual void TrackFeedback(TrackPhase aTrackPhase,
  121.                                 const VPoint& anchorPoint,
  122.                                 const VPoint& previousPoint,
  123.                                 const VPoint& nextPoint,
  124.                                 Boolean mouseDidMove,
  125.                                 Boolean turnItOn);    // Override
  126.  
  127.     virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
  128.                                  VPoint& anchorPoint,
  129.                                  VPoint& previousPoint,
  130.                                  VPoint& nextPoint,
  131.                                  Boolean mouseDidMove);    // Override
  132.  
  133.   private:
  134.     CRect        fBounds;        // Union of extents of all shapes being dragged, before the move
  135.     long        fDeltaH;
  136.     long        fDeltaV;
  137. };
  138.  
  139. //--------------------------------------------------------------------------------------------------
  140. // CLASS TReshadeCmd - 
  141. //--------------------------------------------------------------------------------------------------
  142. class TReshadeCmd : public TTearOffMenuViewTracker
  143. {
  144.     MA_DECLARE_CLASS;
  145.  
  146.   public:
  147.     TReshadeCmd();        // Constructor
  148.     void IReshadeCmd(CommandNumber itsCommandNumber,
  149.                      TShapeView* itsShapeView,
  150.                      TPatternsPalette* thePatternsPalette,
  151.                      TPatternsPalette* menuPatternsPalette,
  152.                      TPatternsPalette* floatingPatternsPalette,
  153.                      const VPoint& theMouse);
  154.  
  155.     virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
  156.                                  VPoint& anchorPoint,
  157.                                  VPoint& previousPoint,
  158.                                  VPoint& nextPoint,
  159.                                  Boolean mouseDidMove);    // Override
  160.  
  161.     virtual void TrackFeedback(TrackPhase aTrackPhase,
  162.                                 const VPoint& anchorPoint,
  163.                                 const VPoint& previousPoint,
  164.                                 const VPoint& nextPoint,
  165.                                 Boolean mouseDidMove,
  166.                                 Boolean turnItOn);    // Override
  167.  
  168.     virtual Boolean IsDoneTracking();    // Override
  169.  
  170.     virtual void DoIt();    // Override
  171.     virtual void UndoIt();    // Override
  172.     virtual void RedoIt();    // Override
  173.  
  174.   private:
  175.     TShapeView*            fShapeView;
  176.     TShapeDocument*        fShapeDocument;
  177.     short                fPattern;
  178.     Boolean                fExitTracking;
  179.     TPatternsPalette*    fMenuPatternsPalette;
  180.     TPatternsPalette*    fFloatingPatternsPalette;
  181. };
  182.  
  183. //--------------------------------------------------------------------------------------------------
  184. // CLASS TRecolorCmd - the set of shapes affected by the reshade request is defined by the
  185. //                       fWasSelected fields of the shapes themselves
  186. //--------------------------------------------------------------------------------------------------
  187. class TRecolorCmd : public TShapeCommand
  188. {
  189.     MA_DECLARE_CLASS;
  190.  
  191.   public:
  192.     TRecolorCmd();        // Constructor
  193.     void IRecolorCmd(CRGBColor itsColor, TShapeView* itsShapeView);
  194.  
  195.     virtual void DoIt();    // Override
  196.     virtual void UndoIt();    // Override
  197.     virtual void RedoIt();    // Override
  198.  
  199.   private:
  200.     CRGBColor    fColor;
  201. };
  202.  
  203. //--------------------------------------------------------------------------------------------------
  204. // CLASS TShapeReplaceCommand - 
  205. //--------------------------------------------------------------------------------------------------
  206. class TShapeReplaceCommand : public TShapeCommand
  207. {
  208.     MA_DECLARE_CLASS;
  209.  
  210.   public:
  211.     TShapeReplaceCommand();        // Constructor
  212.     void IShapeReplaceCommand(CommandNumber itsCommandNumber,
  213.                               TShapeView* itsShapeView,
  214.                               const VPoint& theMouse,
  215.                               Boolean betterFeedbackDesired);
  216.  
  217.     virtual void Commit();    // Override
  218.     virtual void UndoIt();    // Override
  219.     virtual void RedoIt();    // Override
  220.  
  221.     virtual void EachNewShapeDo(DoToShapeType DoToShape, void* staticLink);
  222. };
  223.  
  224. //--------------------------------------------------------------------------------------------------
  225. // CLASS TShapeSketcher - 
  226. //--------------------------------------------------------------------------------------------------
  227. class TShapeSketcher : public TShapeReplaceCommand
  228. {
  229.     MA_DECLARE_CLASS;
  230.  
  231.   public:
  232.     TShapeSketcher();        // Constructor
  233.     void IShapeSketcher(TShapeView* itsShapeView,
  234.                         TShape* protoShape,
  235.                         const VPoint& theMouse,
  236.                         Boolean constrain);
  237.  
  238.     virtual void Free();    // Override
  239.  
  240.     // • Command performing
  241.     virtual void Commit();    // Override
  242.     virtual void DoIt();    // Override
  243.     virtual void UndoIt();    // Override
  244.     virtual void RedoIt();    // Override
  245.  
  246.     virtual void EachNewShapeDo(DoToShapeType DoToShape, void* staticLink);    // Override
  247.  
  248.     virtual void TrackConstrain(TrackPhase aTrackPhase,
  249.                                 const VPoint& anchorPoint,
  250.                                 const VPoint& previousPoint,
  251.                                 VPoint& nextPoint,
  252.                                 Boolean mouseDidMove);    // Override
  253.  
  254.     virtual void TrackFeedback(TrackPhase aTrackPhase,
  255.                                 const VPoint& anchorPoint,
  256.                                 const VPoint& previousPoint,
  257.                                 const VPoint& nextPoint,
  258.                                 Boolean mouseDidMove,
  259.                                 Boolean turnItOn);    // Override
  260.  
  261.     virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
  262.                                  VPoint& anchorPoint,
  263.                                  VPoint& previousPoint,
  264.                                  VPoint& nextPoint,
  265.                                  Boolean mouseDidMove);    // Override
  266.  
  267.   private:
  268.     TShape*        fShape;            // the shape sketched by the user
  269. };
  270.  
  271. //--------------------------------------------------------------------------------------------------
  272. // CLASS TShapeCutCopyCommand - 
  273. //--------------------------------------------------------------------------------------------------
  274. class TShapeCutCopyCommand : public TShapeReplaceCommand
  275. {
  276.     MA_DECLARE_CLASS;
  277.  
  278.   public:
  279.     TShapeCutCopyCommand();        // Constructor
  280.     void IShapeCutCopyCommand(CommandNumber itsCommandNumber,
  281.                               TShapeView* itsShapeView);
  282.  
  283.     virtual void DoIt();    // Override
  284.     virtual void RedoIt();    // Override
  285. };
  286.  
  287. //--------------------------------------------------------------------------------------------------
  288. // CLASS TShapeClearCommand - 
  289. //--------------------------------------------------------------------------------------------------
  290. class TShapeClearCommand : public TShapeReplaceCommand
  291. {
  292.     MA_DECLARE_CLASS;
  293.  
  294.   public:
  295.     TShapeClearCommand();        // Constructor
  296.     void IShapeClearCommand(TShapeView* itsShapeView);
  297.  
  298.     virtual void DoIt();    // Override
  299.     virtual void RedoIt();    // Override
  300. };
  301.  
  302. //--------------------------------------------------------------------------------------------------
  303. // CLASS TShapePasteCommand - 
  304. //--------------------------------------------------------------------------------------------------
  305. class TShapePasteCommand : public TShapeReplaceCommand
  306. {
  307.     MA_DECLARE_CLASS;
  308.  
  309.   public:
  310.     TShapePasteCommand();        // Constructor
  311.     void IShapePasteCommand(TShapeView* itsShapeView);
  312.  
  313.     virtual void Free();    // Override
  314.  
  315.     // • Command performing
  316.     virtual void Commit();    // Override
  317.     virtual void DoIt();    // Override
  318.     virtual void UndoIt();    // Override
  319.     virtual void RedoIt();    // Override
  320.  
  321.     virtual void EachNewShapeDo(DoToShapeType DoToShape, void* staticLink);    // Override
  322.  
  323.     void PasteShapes(CPoint whereToPaste);
  324.     void PastePict(CPoint whereToPaste);
  325.     void PasteText(CPoint whereToPaste);
  326.     
  327.   private:
  328.     TShapeList*        fPasteList;
  329. };
  330.  
  331. #endif
  332.